<%-- 
    Document   : order_step3
    Created on : Feb 9, 2013, 5:51:15 PM
    Author     : SONY
--%>

<%@page import="model.ItemCart"%>
<%@page import="java.util.ArrayList"%>
<%@page import="model.ShoppingCart"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<%
    String error = "";
    if(request.getAttribute("error") != null) {
        error = request.getAttribute("error").toString();
    }
%>
<p style="font-weight:bold;color:red;"><%=error%></p>
<%
    ShoppingCart shopping_cart = (ShoppingCart) session.getAttribute("shopping_cart");
    String fullname = "";
    String address = "";
    String phone = "";
    String paymenttype = "";
    String paymenttype_str = "";
    if(request.getAttribute("Name") != null) {
        fullname = request.getAttribute("Name").toString();
    }
    if(request.getAttribute("Address") != null) {
        address = request.getAttribute("Address").toString();
    }
    if(request.getAttribute("Phone") != null) {
        phone = request.getAttribute("Phone").toString();
    }
    if(request.getAttribute("PaymentType") != null) {
        paymenttype = request.getAttribute("PaymentType").toString();
        if(paymenttype.equals("Cash")) {
            paymenttype_str = "Thanh toán bằng tiền mặt trực tiếp tại địa chỉ giao hàng";
        } else if(paymenttype.equals("CreditCard")) {
            paymenttype_str = "Thanh toán bằng thẻ Credit Card từ tài khoản ngân hàng";
        }
    }
%>
<table id="cart" border=1 cellspacing=0 cellpadding=4 bordercolor=DarkSlateBlue width="100%">
	<tr bgcolor=Tan style="color: white;">
		<th>#</th>
		<th>Hình Ảnh</th>
		<th>Mã SP</th>
		<th>Tên SP</th>
		<th align=center>Đơn Giá (đ)</th>
		<th>Số Lượng</th>
		<th>Thành Tiền (đ)</th>
	</tr>
<% 
    ArrayList<ItemCart> lstItemCart = shopping_cart.getAllItemCart();
    int j = 0;
    for(int i = 0; i < lstItemCart.size(); i++) {
        String color = ++j % 2 == 0 ? "LightGoldenrodYellow" : "PaleGoldenrod";
        String pid = lstItemCart.get(i).getProductID();
        String pname = lstItemCart.get(i).getProductName();
        String imagename = lstItemCart.get(i).getImageName();
        double unitpricefmt = lstItemCart.get(i).getUnitPrice();
        int qty = lstItemCart.get(i).getQuantity();
        double totallinefmt = lstItemCart.get(i).getTotalLine();
%>
	<tr bgcolor="<%=color%>">
		<td align=center><%=j%></td>
		<td align=center><a href="./product_details.jsp?<%=pid%>"><img width=50 title="<%=pname%>" height=50 src="../images/products/<%=imagename%>" /></a></td>
		<td align=center><%=pid%></td>		
		<td align=center><%=pname%></td>
		<td align=center><fmt:formatNumber type="currency" currencySymbol="" maxFractionDigits="0" value="<%=unitpricefmt%>"/></td>
                <td align=center><%=qty%></td>
		<td align=center><fmt:formatNumber type="currency" currencySymbol="" maxFractionDigits="0" value="<%=totallinefmt%>"/></td>
	</tr>

<% } %>
<% double totalfmt = shopping_cart.TotalPrice(); %>
	<tr bgcolor=Tan>
            <td colspan=6 align="right" style="font-weight: bold; color: white;">
                Tổng Tiền (đ) 
            </td>
		<td align="center" style="font-weight: bold">
			<fmt:formatNumber type="currency" currencySymbol="" maxFractionDigits="0" value="<%=totalfmt%>"/>
		</td>
	</tr>
</table>
                <p>&nbsp;</p>
<form name="form1" method="post"  action="<c:url value="/nonmember/order_step3.do" />">
<fieldset class="register" style="width: 580px;">
        <legend class="lgend">Thông Tin Giao Hàng</legend>    
  <table width="550" border="0" cellpadding="5px">
    <tr>
	<td width=150>Họ và Tên :</td>
        <td width=400><%=fullname%></td>
    </tr>
    <tr>
	<td>Địa Chỉ :</td>
	<td><%=address%></td>
    </tr>
    <tr>
	<td>Số Điện Thoại :</td>
	<td><%=phone%></td>
    </tr>
  </table>
</fieldset>
        <p>&nbsp;</p>
<fieldset class="register">
        <legend class="lgend">Hình Thức Thanh Toán</legend>     
<table width="400" border="0" cellpadding="5px">
    <tr>
        <td colspan="2" style="padding-left: 50px;"><%=paymenttype_str%></td>
    </tr>
  </table>
</fieldset>
              <input type="hidden" name="fullname" value="<%=fullname%>"/>
              <input type="hidden" name="address" value="<%=address%>"/>
              <input type="hidden" name="phone" value="<%=phone%>"/>
              <input type="hidden" name="paymenttype" value="<%=paymenttype%>"/>
        <input style="margin-left: 150px; margin-top: 10px;" type="submit" name="btnSubmit" class="btnMask" value='Thay Đổi'/>
        <input type="submit" class="btnMask" name="btnSubmit" value="Xác Nhận"/>
</form> 
